package com.example.myapplication0523.fragment;

import android.os.Bundle;
import android.view.View;
import android.widget.GridView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.myapplication0523.R;
import com.example.myapplication0523.adapter.AliHomeAdapter;
import com.example.myapplication0523.bean.HomeBean;
import com.example.myapplication0523.view.BaseFragment;

import java.util.ArrayList;
import java.util.List;

public class AlipayHomeFragment extends BaseFragment {

    private GridView gv;
    private AliHomeAdapter adapter;

    @Override
    protected int getLayoutID() {
        return R.layout.fragment_alipayhome;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view); //配置组件
    }

    /**
     * 配置组件
     */
    private void initView(View view) {
        gv= view.findViewById(R.id.home_gv);
        adapter= new AliHomeAdapter(getActivity(), new ArrayList<>());
        gv.setNumColumns(5);
        gv.setAdapter(adapter);
    }

    @Override
    protected void init() {
       if (adapter!= null){
           List<HomeBean> list= new ArrayList<>();
           list.add(new HomeBean("转账", R.mipmap.icon_bill));
           list.add(new HomeBean("信用卡还款", R.mipmap.icon_property));
           list.add(new HomeBean("手机充值", R.mipmap.icon_balance));
           list.add(new HomeBean("余额宝", R.mipmap.icon_balancebao));
           list.add(new HomeBean("高德打车", R.mipmap.icon_hb));
           list.add(new HomeBean("市民中心", R.mipmap.icon_ylb));
           list.add(new HomeBean("花呗", R.mipmap.icon_numberyuan));
           list.add(new HomeBean("芝麻信用", R.mipmap.icon_card));
           list.add(new HomeBean("火车票机票", R.mipmap.icon_ant));
           list.add(new HomeBean("蚂蚁森林", R.mipmap.icon_bill));
           list.add(new HomeBean("淘票票", R.mipmap.icon_balance));
           list.add(new HomeBean("我的小程序", R.mipmap.icon_property));
           list.add(new HomeBean("更多", R.mipmap.icon_more));

           adapter.setNewList(list);
       }
    }
}
